package tw.asap.plus.app;

import android.app.Application;
import android.content.Context;
import android.os.Build;

import com.facebook.drawee.backends.pipeline.Fresco;

import timber.log.Timber;
import tw.asap.plus.BuildConfig;
import tw.asap.plus.common.ConstValue;
import tw.asap.plus.utils.ApkUtil;
import tw.asap.plus.utils.SPUtil;
import tw.asap.plus.utils.Utils;

/**
 * Created by yamlee on 15/8/7.
 */
public class NearApplication extends Application{
    private static Context mContext;

    @Override
    public void onCreate() {
        super.onCreate();
        mContext = this.getApplicationContext();
        settingLogTool();
        initCommonProperty();
        Fresco.initialize(this);
    }

    private void initCommonProperty() {

        SPUtil spUtil = SPUtil.getInstance(this);
        spUtil.save(ConstValue.Sp.APP_VERSION, Utils.getAppVersion(this));
        spUtil.save(ConstValue.Sp.SYSTEM_VERSION, Build.VERSION.SDK);
        spUtil.save(ConstValue.Sp.IMEI_NO, Utils.getDeviceId(this));
        spUtil.save(ConstValue.Sp.CHANNEL, ApkUtil.getMetaData(this));

    }

    public static Context getNearApplicationContext(){
        return mContext;
    }

    /**
     * log日志类库------支持自定义标签、默认是类名
     */
    private void settingLogTool() {
        if (BuildConfig.DEBUG) {
            Timber.plant(new Timber.DebugTree());
        }
    }


}
